package com.jk.bgmainconsumer.controller;

import com.jk.bgmainconsumer.entity.IndentEntity;
import com.jk.bgmainconsumer.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("echarts")
public class EchartsController {
    @Autowired
    private EchartsService echartsService;

    @RequestMapping("findEcharts")
    public List<IndentEntity>findEcharts(){

        return echartsService.findEcharts();
    }
    @RequestMapping("findEcharts2")
    public List cha1(){
        List<IndentEntity> cha = echartsService.findEcharts();
        List<Map> list = new ArrayList<Map>();
        for (int i = 0; i < cha.size(); i++) {
            Map map=new HashMap<>();
            map.put("value", cha.get(i).getRealityShopTotal());
            map.put("name", cha.get(i).getBuyUserName());
            System.out.println(map);
            list.add(i, map);
            System.out.println(list);
        }
        return list;
    }

}
